#!/bin/bash

set +e


IPPrefix="192.168.8."
curPath=$(dirname $(readlink -f "$0"))
PASSWD=$(cat $curPath/../.env)


if [ -z "$1"  ]; then

  # for i in {9..13} {16..32}
  for i in {101..116}  
  # for i in {18..32}
  do

    echo "------link--> $IPPrefix$i---------"
    if(($i==2 || $i==14 || $i==15 || $i==34 || $i==200)); then
      echo "跳过 主机器..."
      echo "--------------------------------"
      echo ""
      continue
    fi

    if [ -z "$2"   ]
    then
      sleep 1
    fi

    # bash ./g_service.sh $i ap
    bash ./g_service.sh $i p1
    bash ./g_service.sh $i pcto1
    bash ./g_service.sh $i pcto2

    echo "--------------------------------"
    echo ""
  done
else
  echo "----------------- stop---------------"
  # for i in {238..246}
  # do

  #   echo "------link--> $IPPrefix$i---------"

  #   if [ -z "$2"   ]
  #   then
  #     sleep 1
  #   fi

  #   bash ~/miner-sh/service/g_service.sh $i ap
  #   bash ~/miner-sh/service/g_service_9.sh $i p1
  #   bash ~/miner-sh/service/g_service_9.sh $i pcto1
  #   bash ~/miner-sh/service/g_service_9.sh $i pcto2

  #   echo "--------------------------------"
  #   echo ""
  # done
fi








# # 批量创建
# bash ~/miner-sh/install/dev_gserv.sh

# # 运行
# bash ~/miner-sh/install/dev_22.sh  "sudo systemctl start  worker-ap"
# bash ~/miner-sh/install/dev_22.sh  "sudo systemctl start  worker-p1"
# bash ~/miner-sh/install/dev_22.sh  "sudo systemctl start  worker-pcto1"
# bash ~/miner-sh/install/dev_22.sh  "sudo systemctl start  worker-pcto2"


#  bash ~/miner-sh/install/dev_22.sh "sudo systemctl stop  worker-ap && sudo systemctl stop  worker-p1 && sudo systemctl stop  worker-pcto1 && sudo systemctl stop  worker-pcto2"


# bash ~/miner-sh/install/dev_22.sh "sudo systemctl start  worker-ap && sudo systemctl start  worker-p1 && sudo systemctl start  worker-pcto1 && sudo systemctl start  worker-pcto2"